package cn.com.kh;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckPhoneNo {

    public static boolean check(String str) {

        // 邮箱验证规则
        String regExTel = "^(0\\d{2,3}\\-)?([2-9]\\d{6,7})+(\\-\\d{1,6})?$";
        String regExMobile = "^((\\+86|\\+86\\-)|(86|86\\-)|(0086|0086\\-))?1[3|4|5|6|7|8|9]\\d{9}$";
        // 编译正则表达式
        Pattern patternTel = Pattern.compile(regExTel);
        Pattern patternMobile = Pattern.compile(regExMobile);
        // 忽略大小写的写法
        // Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
        Matcher matcherTel = patternTel.matcher(str);
        Matcher matcherMobile = patternMobile.matcher(str);
        // 字符串是否与正则表达式相匹配
        boolean rsTel = matcherTel.matches();
        boolean rsMobile = matcherMobile.matches();

        if (rsTel || rsMobile) {
            return true;
        } else {
            return false;
        }

    }

}